import request from '@/utils/request';
import qs from "qs";

export async function orderPage(params) {
  const limit = params.pageSize;
  const page = params.current;
  const my_params = {
    limit: limit,
    page: page
  };
  Object.assign(params, my_params);
  delete params.current;
  delete params.pageSize;
  params.type = "1";
  return request('/supplyChain/order/page', {
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}
export async function getOrderDetail(params) {
  return request(`/supplyChain/order/details`, {
    params
  });
}
export async function getOrderDetailByIds(params) {
  return request(`/supplyChain/order/detailsByIds`, {
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}
export async function exportPrinter(params) {
  return request(`/supplyChain/order/printer`, {
    method: 'GET',
    responseType: 'blob',
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}
export async function exportDriverPrinter(params) {
  return request(`/supplyChain/order/driverPrinter`, {
    method: 'GET',
    responseType: 'blob',
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}
export async function changeMoney(data) {
  return request('supplyChain/driver/order/changeMoney', {
    method: 'POST',
    data
  });
}
export async function updateOrder(data) {
  return request('supplyChain/order/updateOrder', {
    method: 'POST',
    data
  });
}
export async function confirmOrder(data) {
  return request('supplyChain/order/confirmOrder', {
    method: 'POST',
    data
  });
}
export async function confirmDriver(data) {
  return request('supplyChain/order/confirmDriver', {
    method: 'POST',
    data
  });
}
export async function delDriver(data) {
  return request('supplyChain/order/delDriver', {
    method: 'POST',
    data
  });
}
export async function delOrder(data) {
  return request('supplyChain/order/delOrder', {
    method: 'POST',
    data
  });
}
export async function revokeOrder(data) {
  return request('supplyChain/order/revokeOrder', {
    method: 'POST',
    data
  });
}
export async function addDriverDetails(data) {
  return request('supplyChain/order/addDriverDetails', {
    method: 'POST',
    data
  });
}
export async function addDriverDetailsByOrders(data) {
  return request('supplyChain/order/addDriverDetailsByOrders', {
    method: 'POST',
    data
  });
}

export async function delPayFile(data) {
  return request(`/supplyChain/purchase/delFile`, {
    method: 'POST',
    data
  });
}
export async function getPayFiles(params) {
  return request(`/supplyChain/driver/getPayFiles`, {
    params
  });
}
export async function exportDriverDetails(params) {
  return request(`supplyChain/purchase/exportDriverDetails`, {
    method: 'GET',
    responseType: 'blob',
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}
